package observable;

import java.util.EventObject;

/**
 * create by yongli on 2021-07-04 14:23
 */
class PersonSpeakEvent extends EventObject {
    String content;

    //从这个构造函数的source才是我们监听的对象，EventObject只是这个Listener的桥梁。
    public PersonSpeakEvent(Object source) {
        super(source);
    }

    @Override
    public Object getSource() {
        return super.getSource();
    }

    @Override
    public String toString() {
        return super.toString();
    }

    public void speak(String content) {
        this.content = content;
        System.out.println(content);
    }
}
